﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using FileParser;

namespace FileAggregator
{
    class Program
    {
        static void Main(string[] args)
        {
            Dictionary<string, int> dick =new Dictionary<string,int>();
            string path = args[0];
           
            using (FileStream fs = File.OpenRead(path))
            {

                using (StreamReader sr = new StreamReader(fs))
                {
                    string line;
                    while ((line = sr.ReadLine()) != null)
                    {
                        string key = line.Split(' ')[0];
                        int value = Convert.ToInt32(line.Split(' ')[1]);

                        if (dick.ContainsKey(line.Split(' ')[0]))
                        {
                            dick[key] += value;
                            continue;
                        }
                            dick.Add(line.Split(' ')[0],Convert.ToInt32(line.Split(' ')[1]));
                    }
                }

                foreach (string s in dick.Keys)
                                Console.WriteLine(s+" "+dick[s]);
                Console.ReadKey();
            }

        }
    }
}
